Lack Of Cohesion Of Methods 3 (LCOM3)

Description:

Measures the dissimilarity of methods in a class by its attributes.

Consider:
m - number of methods in a class
a - number of attributes in a class
mA - number of methods that access an attribute
EmA - sum of mA for each attribute

Then:
RESULT = 100*(EmA/a-m)/(1-m)

The definition of this metric was proposed by Henderson-Sellers in 1995. A low value indicates good class subdivision, implying simplicity and high reusability. A high lacking of cohesion increases complexity, thereby increasing the likelihood of errors during the development process.

If there are no more than one method in a class, LCOM3 is undefined. If there are no variables in a class, LCOM3 is undefined. An undefined LCOM3 is displayed as -1. Methods that do not access any class variables are not taken into account.